﻿using System;
using System.Collections.Generic;
using System.Text;
using NIIT.SaoBacDau.Aupi.HospitalManagement.Entities;
using System.Data.SqlClient;
using System.Data;

namespace NIIT.SaoBacDau.Aupi.HospitalManagement.DataAccess
{
    public class DAO_F_TypeMedical
    {
        public static List<F_TypeMedical> ListTypeMedical()
        {
            SqlDataAdapter sqldata = new SqlDataAdapter("Form.Medical", DAO_ConnectDatabase.Connect());
            sqldata.SelectCommand.CommandType = CommandType.StoredProcedure;
            DataTable dtable = new DataTable();
            sqldata.Fill(dtable);
            List<F_TypeMedical> List = new List<F_TypeMedical>();
            foreach (DataRow dr in dtable.Rows)
            {
                F_TypeMedical objTypeMedical = new F_TypeMedical();
                objTypeMedical.TypeMedicalID = Convert.ToInt32(dr["TypeMedicalID"].ToString());
                objTypeMedical.NameMedical = dr["NameMedical"].ToString();
                List.Add(objTypeMedical);
            }
            return List;
        }

        public static F_TypeMedical TypeMedical(F_TypeMedical f_Type)
        {
            SqlDataAdapter sqldata = new SqlDataAdapter("[Form].[F_Medical]", DAO_ConnectDatabase.Connect());
            sqldata.SelectCommand.CommandType = CommandType.StoredProcedure;
            sqldata.SelectCommand.Parameters.Add("@TypeMedicalID", SqlDbType.Int).Value = f_Type.TypeMedicalID;
            DataTable dtable = new DataTable();
            sqldata.Fill(dtable);
            F_TypeMedical objTypeMedical = new F_TypeMedical();
            objTypeMedical.TypeMedicalID = Convert.ToInt32(dtable.Rows[0]["TypeMedicalID"].ToString());
            objTypeMedical.NameMedical = dtable.Rows[0]["NameMedical"].ToString();
            return objTypeMedical;
        }
    }
}
